﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Common;
using System.Data.SqlClient;
using System.Data;

namespace CAD.DAO
{
   public class DAODepreciacion
    {

       public int Insertar(int ITIEMPO, string SDESCRIPCION_DSC, int ICONCURRENCIA)
        {
            List<DbParameter> lstParametros = new List<DbParameter>();
            DbParameter prmA = new SqlParameter();
            prmA.DbType = DbType.Int32;
            prmA.ParameterName = "@LDEPRECIACION_ID";
            prmA.Direction = ParameterDirection.Output;
            lstParametros.Add(prmA);

            DbParameter prmB = new SqlParameter();
            prmB.DbType = DbType.Int32;
            prmB.ParameterName = "@ITIEMPO";
            prmB.Value = ITIEMPO;
            prmB.Direction = ParameterDirection.Input;
            lstParametros.Add(prmB);

            DbParameter prmC = new SqlParameter();
            prmC.DbType = DbType.String;
            prmC.ParameterName = "@SDESCRIPCION_DSC";
            prmC.Value = SDESCRIPCION_DSC;
            prmC.Direction = ParameterDirection.Input;
            lstParametros.Add(prmC);

            DbParameter prmCW = new SqlParameter();
            prmCW.DbType = DbType.Int32;
            prmCW.ParameterName = "@ICONCURRENCIA";
            prmCW.Value = 1;
            prmCW.Direction = ParameterDirection.Input;
            lstParametros.Add(prmCW);

            DbParameter prmD = new SqlParameter();
            prmD.DbType = DbType.Int32;
            prmD.ParameterName = "@iEvento";
            prmD.Value = 1;
            prmD.Direction = ParameterDirection.Input;
            lstParametros.Add(prmD);

            SQLConexion conProxy = new SQLConexion();
            if (conProxy.EjecutarDML(lstParametros, "dbo.SPABM_DEPRECIACION"))
                return Convert.ToInt32(prmA.Value);
            return -1;

        }
       public bool Actualizar(int LDEPRECIACION_ID, int ITIEMPO, string SDESCRIPCION_DSC, int ICONCURRENCIA)
        {
            List<DbParameter> lstParametros = new List<DbParameter>();

            DbParameter prmA = new SqlParameter();
            prmA.DbType = DbType.Int32;
            prmA.ParameterName = "@LDEPRECIACION_ID";
            prmA.Value = LDEPRECIACION_ID;
            prmA.Direction = ParameterDirection.Input;
            lstParametros.Add(prmA);

            DbParameter prmB = new SqlParameter();
            prmB.DbType = DbType.Int32;
            prmB.ParameterName = "@ITIEMPO";
            prmB.Value = ITIEMPO;
            prmB.Direction = ParameterDirection.Input;
            lstParametros.Add(prmB);

            DbParameter prmC = new SqlParameter();
            prmC.DbType = DbType.String;
            prmC.ParameterName = "@SDESCRIPCION_DSC";
            prmC.Value = SDESCRIPCION_DSC;
            prmC.Direction = ParameterDirection.Input;
            lstParametros.Add(prmC);

            DbParameter prmCW = new SqlParameter();
            prmCW.DbType = DbType.Int32;
            prmCW.ParameterName = "@ICONCURRENCIA";
            prmCW.Value = ICONCURRENCIA;
            prmCW.Direction = ParameterDirection.Input;
            lstParametros.Add(prmCW);

            DbParameter prmD = new SqlParameter();
            prmD.DbType = DbType.Int32;
            prmD.ParameterName = "@iEvento";
            prmD.Value = 2;
            prmD.Direction = ParameterDirection.Input;
            lstParametros.Add(prmD);


            SQLConexion conProxy = new SQLConexion();
            return conProxy.EjecutarDML(lstParametros, "dbo.SPABM_DEPRECIACION");
        }
       public bool Eliminar(int LDEPRECIACION_ID)
        {
            List<DbParameter> lstParametros = new List<DbParameter>();

            DbParameter prmA = new SqlParameter();
            prmA.DbType = DbType.Int32;
            prmA.ParameterName = "@LDEPRECIACION_ID";
            prmA.Value = LDEPRECIACION_ID;
            prmA.Direction = ParameterDirection.Input;
            lstParametros.Add(prmA);
            DbParameter prmD = new SqlParameter();
            prmD.DbType = DbType.Int32;
            prmD.ParameterName = "@iEvento";
            prmD.Value = 3;
            prmD.Direction = ParameterDirection.Input;
            lstParametros.Add(prmD);
            SQLConexion conProxy = new SQLConexion();
            return conProxy.EjecutarDML(lstParametros, "dbo.SPABM_DEPRECIACION");
        }
        public DataSet Traer()
        {
            List<DbParameter> lstParametros = new List<DbParameter>();
            DbParameter prmD = new SqlParameter();
            prmD.DbType = DbType.Int32;
            prmD.ParameterName = "@iEvento";
            prmD.Value = 4;
            prmD.Direction = ParameterDirection.Input;
            lstParametros.Add(prmD);
            SQLConexion conProxy = new SQLConexion();
            return conProxy.EjecutarConsulta(lstParametros, "dbo.SPABM_DEPRECIACION");
        }
        public DataSet TraerXId(int LDEPRECIACION_ID)
        {
            List<DbParameter> lstParametros = new List<DbParameter>();
            DbParameter prmA = new SqlParameter();
            prmA.DbType = DbType.Int32;
            prmA.ParameterName = "@LDEPRECIACION_ID";
            prmA.Value = LDEPRECIACION_ID;
            prmA.Direction = ParameterDirection.Input;
            lstParametros.Add(prmA);

            DbParameter prmD = new SqlParameter();
            prmD.DbType = DbType.Int32;
            prmD.ParameterName = "@iEvento";
            prmD.Value = 5;
            prmD.Direction = ParameterDirection.Input;
            lstParametros.Add(prmD);
            SQLConexion conProxy = new SQLConexion();

            return conProxy.EjecutarConsulta(lstParametros, "dbo.SPABM_DEPRECIACION");
        }
        
    }
}
